package com.xvdong.audioplayer;

import android.app.Dialog;
import android.content.Context;

import com.xvdong.audioplayer.adapter.LyricsListAdapter;
import com.xvdong.audioplayer.interfaces.OnDataListener;
import com.xvdong.audioplayer.model.WYAudio;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

/**
 * Created by xvDong on 2024/3/27.
 */

public class LyricsListDialog extends Dialog {

    public LyricsListDialog(@NonNull Context context, List<WYAudio.ResultBean.SongsBean> lyrics, OnDataListener<Long> listener) {
        super(context);
        setContentView(R.layout.dialog_lyrics_list);
        RecyclerView recyclerView = findViewById(R.id.rv_lyrics);
        recyclerView.setLayoutManager(new LinearLayoutManager(context));

        LyricsListAdapter lyricsListAdapter = new LyricsListAdapter(context, lyrics, data -> {
            if (listener != null){
                listener.onDataListener(data);
            }
            dismiss();
        });
        recyclerView.setAdapter(lyricsListAdapter);
    }

}
